// pages/mine/choosePeople.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: "",
    postType: "",
    claimUid: "",
    uid: "",
    contactList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id: options.id,
      postType: options.postType,
      contactList: wx.getStorageSync('contactList'),
      uid: wx.getStorageSync('userinfo').uid
    })
    console.log(wx.getStorageSync('contactList'))
  },
  async chooseThis(e) {
    var id = this.data.id
    var claimUid = e.currentTarget.dataset.uid
    var uid = this.data.uid
    var postType = this.data.postType
    if (postType == 1) {
      wx.showModal({
        title: '提示',
        content: '确认指定该联系人为失主？',
        success: async function () {
          await wx.User.confirmClaimFound({
            data: {
              id: id,
              claimUid: claimUid,
              uid: uid
            }
          })
          setTimeout(function () {
            wx.switchTab({
              url: '/pages/mine/mine',
            })
          }, 1000);
        }
      })
    } else if (postType == 0) {
      wx.showModal({
        title: '提示',
        content: '确认指定该联系人为帮助者？',
        success: async function () {
          await wx.User.confirmClaimLost({
            data: {
              id: id,
              claimUid: claimUid,
              uid: uid
            }
          })
          setTimeout(function () {
            wx.switchTab({
              url: '/pages/mine/mine',
            })
          }, 1000);
        }
      })
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})